import request from '@/config/axios'

// 告警触发器 VO
export interface AlarmTriggerVO {
  id: number // ID
  name: string // 触发器名称
  thresholdLevelNum: number // 阈值级数
  debounceSeconds: number // 防抖条件(N秒内发生)
  debounceNum: number // 防抖条件(发生N次)
  pushPlatform: string // 推送平台(1:钉钉,2:飞书,3:企业微信)
  notifyTemplateId: number // 通知模板ID
  conditionJson: string // 条件json
  thresholJson: string // 阈值json
  ruleId: number // 规则ID
}

// 告警触发器 API
export const AlarmTriggerApi = {
  // 查询告警触发器分页
  getAlarmTriggerPage: async (params: any) => {
    return await request.get({ url: `/vmiot/alarm-trigger/page`, params })
  },

  // 查询告警触发器详情
  getAlarmTrigger: async (id: number) => {
    return await request.get({ url: `/vmiot/alarm-trigger/get?id=` + id })
  },

  // 新增告警触发器
  createAlarmTrigger: async (data: AlarmTriggerVO) => {
    return await request.post({ url: `/vmiot/alarm-trigger/create`, data })
  },

  // 修改告警触发器
  updateAlarmTrigger: async (data: AlarmTriggerVO) => {
    return await request.put({ url: `/vmiot/alarm-trigger/update`, data })
  },

  // 删除告警触发器
  deleteAlarmTrigger: async (id: number) => {
    return await request.delete({ url: `/vmiot/alarm-trigger/delete?id=` + id })
  },

  // 导出告警触发器 Excel
  exportAlarmTrigger: async (params) => {
    return await request.download({ url: `/vmiot/alarm-trigger/export-excel`, params })
  }
}